//
//  LearnView.m
//  汽车大灯色温蓝牙
//
//  Created by dfwx on 2020/9/10.
//  Copyright © 2020 zhongdaodianzi. All rights reserved.
//

#import "LearnView.h"

@implementation LearnView

- (void)awakeFromNib {
    
    [super awakeFromNib];
    self.lastButton.layer.borderWidth = 1;
    self.lastButton.layer.borderColor = UIColorFromHex(0x3ABCDE).CGColor;
    self.lastButton.layer.cornerRadius = 22;
    self.lastButton.layer.masksToBounds = YES;
    
    self.nextButton.layer.borderWidth = 1;
    self.nextButton.layer.borderColor = UIColorFromHex(0x3ABCDE).CGColor;
    self.nextButton.layer.cornerRadius = 22;
    self.nextButton.layer.masksToBounds = YES;
    
    [self.lastButton setTitle:WWNSLocalizedString(@"lastStep", @"") forState:UIControlStateNormal];
    [self.nextButton setTitle:WWNSLocalizedString(@"nextStep", @"") forState:UIControlStateNormal];
    self.closeLabel.text = WWNSLocalizedString(@"CloseButtonTitle", @"");

    self.index = 1;
}

- (IBAction)lastButtonClicked:(UIButton *)sender {
    if (self.index > 1) {
        self.index --;
    }
}

- (IBAction)nextButtonClicked:(UIButton *)sender {
    if (self.index < 10) {
        self.index ++;
    }
}

- (IBAction)closeButtonClicked:(UIButton *)sender {
    
    [self removeFromSuperview];
}

- (void)setIndex:(NSInteger)index {
    
    _index = index;
    if (index <= 1) {
        [self.lastButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        self.lastButton.userInteractionEnabled = NO;
        
        [self.nextButton setTitleColor:UIColorFromHex(0x3ABCDE) forState:UIControlStateNormal];
        self.nextButton.userInteractionEnabled = YES;
        
        self.lastButton.layer.borderColor = [UIColor lightGrayColor].CGColor;
        self.nextButton.layer.borderColor = UIColorFromHex(0x3ABCDE).CGColor;

    }else if (index >= 10) {
        
        [self.nextButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        self.nextButton.userInteractionEnabled = NO;
        
        [self.lastButton setTitleColor:UIColorFromHex(0x3ABCDE) forState:UIControlStateNormal];
        self.lastButton.userInteractionEnabled = YES;
        
        self.nextButton.layer.borderColor = [UIColor lightGrayColor].CGColor;
        self.lastButton.layer.borderColor = UIColorFromHex(0x3ABCDE).CGColor;
    }else {
        [self.lastButton setTitleColor:UIColorFromHex(0x3ABCDE) forState:UIControlStateNormal];
        self.lastButton.userInteractionEnabled = YES;
        
        [self.nextButton setTitleColor:UIColorFromHex(0x3ABCDE) forState:UIControlStateNormal];
        self.nextButton.userInteractionEnabled = YES;
        
        self.lastButton.layer.borderColor = UIColorFromHex(0x3ABCDE).CGColor;
        self.nextButton.layer.borderColor = UIColorFromHex(0x3ABCDE).CGColor;

    }
    
    self.backImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@%02ld.jpg",NSLocalizedString(@"explain01", @"explain"),self.index]];
}


@end
